Skip to content

perf(rendering): render each view at most once per frame - #1037

Merged
PaulHax merged 1 commit into
Kitware:mainfrom
PaulHax:render-frame-scheduler
Nov 17, 2026
Merged

PaulHax merged 1 commit into
Kitware:mainfrom
PaulHax:render-frame-scheduler

Conversation

@PaulHax

@PaulHax PaulHax commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

After #1034, a single change could still render a view several times before the next frame was shown. The app, vtk.js widgets, and the vtk interactor each asked for renders independently, and each one drew.

This change gives every view one render per frame:

  • The view's interactor is created with enableRender: false, so vtk.js's own render() calls only emit RenderEvent, which the view turns into a render request. vtk-initiated renders join the app's requests instead of drawing immediately. Frames of vtk's interaction animation, during drags and wheel zoom, draw when vtk asks for them.
  • Requests are batched with batchAfterNextFrame, which renders in a task after the next animation frame. Chrome runs a frame after each discrete input event, so rendering inside the requestAnimationFrame callback drew once per key press on slow views; for example, each arrow key on the en face slab slider got its own projection render. Running the render in a task after the frame lets queued input coalesce first. Updates appear in the frame after the input, as with the previous next-task batching.
  • A request made while the view is rendering is dropped, since vtk modifies what it draws during the draw.
  • The view's size comes from a single resize observer. Views without area skip rendering until they gain area. VtkSliceView fits the camera on the view's window resize event, so the render that follows already shows the fit.

Not covered: during interaction, vtk's interactor animation loop still renders every frame even when nothing changed, for example in the tail after mouse wheel input.

@netlify

netlify Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for volview-dev ready!

Name Link
🔨 Latest commit c40867f
🔍 Latest deploy log https://app.netlify.com/projects/volview-dev/deploys/6afbba0d5851edae8f1edcdd
😎 Deploy Preview https://deploy-preview-1037--volview-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@PaulHax
PaulHax force-pushed the render-frame-scheduler branch 4 times, most recently from 1399efa to 6bba109 Compare November 16, 2026 21:52
@PaulHax
PaulHax marked this pull request as ready for review November 16, 2026 22:27
@PaulHax
PaulHax force-pushed the render-frame-scheduler branch from 6bba109 to d2954ce Compare November 16, 2026 23:46
Render requests from the app and from vtk.js now share one render per
view per frame. The vtk interactor's own render calls become requests,
and a request made while rendering is dropped. The render runs in a task
after the frame, so queued input is handled before drawing. View size
comes from one resize observer, and slice views fit the camera on the
view's resize event.
@PaulHax
PaulHax force-pushed the render-frame-scheduler branch from d2954ce to c40867f Compare November 17, 2026 02:20
@PaulHax
PaulHax merged commit 2291c73 into Kitware:main Nov 17, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant